package com.ylbh.modules.reply.controller;

import com.aliyuncs.CommonRequest;
import com.ylbh.common.annotation.SysLog;
import com.ylbh.common.pojo.reply.dto.AddOrModifyReplyDTO;
import com.ylbh.common.pojo.reply.dto.CommunalDTO;
import com.ylbh.common.utils.CommonResult;
import com.ylbh.common.utils.PageUtils;
import com.ylbh.common.utils.Ref;
import com.ylbh.modules.reply.entity.ShoppingReply;
import com.ylbh.modules.reply.entity.ShoppingReplyType;
import com.ylbh.modules.reply.service.ShoppingReplyTypeService;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiOperation;
import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import org.springframework.web.multipart.MultipartFile;

import java.util.Arrays;
import java.util.List;

/**
 * 回复类型管理
 * @author wjc
 * @date 2019-10-17 11:04:15
 */
@RestController
@RequestMapping("replyType")
public class ShoppingReplyTypeController {

    @Autowired
    private ShoppingReplyTypeService shoppingReplyTypeService;

    @ApiOperation("帮助回复类型列表")
    @RequestMapping("queryReplyTypeList")
    public CommonResult<PageUtils> queryReplyTypeList(CommunalDTO typeDTO){
        PageUtils replyTypeList = shoppingReplyTypeService.queryReplyTypeList(typeDTO);
        return Ref.ok(replyTypeList);
    }

    @SysLog("修改类型表状态")
    @ApiOperation("修改类型表状态")
    @RequestMapping("modifyReplyTypeEnableStateById")
    public CommonResult<Void> modifyReplyTypeEnableStateById(@RequestBody CommunalDTO communalDTO){
        shoppingReplyTypeService.modifyReplyTypeEnableStateById(communalDTO);
        return Ref.ok();
    }

    @ApiOperation("上传类型图片")
    @RequestMapping("uploadTypeImg")
    public CommonResult<String> uploadTypeImg(MultipartFile file){
        String url = shoppingReplyTypeService.uploadTypeImg(file);
        return Ref.ok(url);
    }

    @ApiOperation("问题类型新增")
    @RequestMapping("addReplyTypeClass")
    public CommonResult addReplyTypeClass(@RequestBody ShoppingReplyType shoppingReplyType){
        shoppingReplyTypeService.addReplyTypeClass(shoppingReplyType);
        return Ref.ok();
    }

    @SysLog("根据ID回显回复类型信息")
    @ApiOperation("根据ID回显回复类型信息")
    @GetMapping("getReplyTypeClassById/{typeId}")
    public  CommonResult getReplyTypeClassById(@PathVariable String typeId) {
        ShoppingReplyType shoppingReplyType  = shoppingReplyTypeService.getReplyTypeClassById(typeId);
        return Ref.ok(shoppingReplyType);
    }

    @SysLog("根据ID删除回复类型信息")
    @ApiOperation("根据ID删除回复类型信息")
    @RequestMapping("removeReplyTypeClassById/{typeId}")
    public CommonResult<Void> removeReplyTypeClassById(@PathVariable String typeId){
        shoppingReplyTypeService.removeReplyTypeClassById(typeId);
        return Ref.ok();
    }

    @SysLog("根据ID修改回复类型信息")
    @ApiOperation("根据ID修改回复类型信息")
    @RequestMapping("modifyReplyTypeClassById")
    public  CommonResult modifyReplyTypeClassById(@RequestBody ShoppingReplyType shoppingReplyType) {
        shoppingReplyTypeService.modifyReplyTypeClassById(shoppingReplyType);
        return Ref.ok();
    }

    @ApiOperation("类型名称反回")
    @RequestMapping("queryTypeNameList")
    public CommonResult<List<ShoppingReplyType>> queryTypeNameList(){
        List<ShoppingReplyType> list = shoppingReplyTypeService.queryTypeNameList();
        return Ref.ok(list);
    }
}
